#!/usr/bin/env node

const cp = require('child_process');

console.log('I am father process:' ,process.pid);

process.send(process.pid);

let son = cp.fork('./11-ipc-child.js'),
    dau = cp.fork('./11-ipc-child.js');

process.on('message',(data)=>{
  console.log('I have babies:',data);
});

setTimeout(()=>{
  son.send('Good Good Study');
},2000);

setTimeout(()=>{
  dau.send('Day Day Up');
},3000);

setTimeout(()=>{
  son.kill('SIGINT');
  dau.kill('SIGINT');
},5000);

//虽然父子进程分离，但父进程可控制子进程的存在
